package com.modernyuanshiren;

import java.util.List;

public final class InfoUtil {
	public static double getInfo(Guess guess, List<Guess> list) {
		return Result
				.getAvailableResults(guess.getLength())
				.parallelStream()
				.map(r -> new Record(guess, r))
				.mapToLong(
						record -> list.parallelStream()
								.filter(item -> item.match(record)).count())
				.mapToDouble(pi -> pi / list.size())
				.map(div -> div == 0 ? 0 : -div * Math.log(div)).sum();
	}
}
